package cn.yunhe.model;

import cn.yunhe.YangLeGeYangApp;
import cn.yunhe.util.MapUtil;
import cn.yunhe.util.TransverseMapUtil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 图层类：横向一维表格
 */
public class TransverseMap extends Component {

    //层⾼，有⼏张图层，游戏难度相关
    private int floorHeight;
    private List<Layer> list = new ArrayList<>();

    public int getFloorHeight() {
        return floorHeight;
    }

    public void setFloorHeight(int floorHeight) {
        this.floorHeight = floorHeight;
    }

    public List<Layer> getList() {
        return list;
    }

    public void setList(List<Layer> list) {
        this.list = list;
    }


    /**
     * 判断当前map中所有牌，是否置灰
     */
    public void compareAll() {
        if (list.size() != 0) {
            Cell[][] cells = list.get(0).getCells();
            for (int i = 0; i < cells[0].length; i++) {
                if (cells[0][i] == null || cells[0][i].getBrand() == null) {
                    break;
                }
                cells[0][i].getBrand().setGray(true);
            }
            if (cells[0][0] != null && cells[0][0].getBrand() != null) {
                cells[0][0].getBrand().setGray(false);
            }
            for (int i = 0; i < cells[0].length; i++) {
                if (cells[0][i] == null || cells[0][i].getBrand() == null) {
                    continue;
                } else {
                    cells[0][i].getBrand().setGray(false);
                    break;
                }

            }
        }
    }

}
